
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/timer.h>
#include <linux/slab.h>
#include <asm/cacheflush.h>

MODULE_AUTHOR("mdy");
MODULE_DESCRIPTION("demo");
MODULE_LICENSE("GPL");

static int __init ioremap_demo_init(void)
{
    
    void* p = kmalloc(1024, GFP_KERNEL);
    unsigned long phyaddr = virt_to_phys(p);
    void* q = ioremap_cache(phyaddr, 1024);
    printk("p = %px, q = %px\n", p, q);

    {
        int before = *(int*)p, after = 0;
        *(int*)q = 12345678;
        after = *(int*)p;
        printk("before = %d, after = %d\n", before, after);
    }

    return 0;
}

static void __exit ioremap_demo_exit(void)
{
    return;
}
 
module_init(ioremap_demo_init);
module_exit(ioremap_demo_exit);

